<!DOCTYPE html>
<html lang="en">

<head>
	<title>登录</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="keywords" content="Techno Login Form Responsive, Login Form Web Template, Flat Pricing Tables, Flat Drop-Downs, Sign-Up Web Templates, Flat Web Templates, Login Sign-up Responsive Web Template, Smartphone Compatible Web Template, Free Web Designs for Nokia, Samsung, LG, Sony Ericsson, Motorola Web Design">
	<script type="application/x-javascript">
		addEventListener("load", function () {
			setTimeout(hideURLbar, 0);
		}, false);

		function hideURLbar() {
			window.scrollTo(0, 1);
		}
	</script>
	<link rel="stylesheet" href="PUBLIC/css/mdl/material.css">
	<script defer src="PUBLIC/css/mdl/material.min.js"></script>
	<link rel="stylesheet" type="text/css" href="PUBLIC/css/styles.css">
	<script type="text/javascript" src="PUBLIC/jquery/jquery.js"></script>
	<link rel="stylesheet" href="PUBLIC/css/loginstyle.css" type="text/css" media="all">
</head>

<body>

	<div class="aitsloginwthree w3layouts agileits">
		<h2 style="margin-top:200px">登录</h2>
		<input id="Username" type="text" Name="Username" placeholder="Username" required="">
		<input id="Password" type="password" Name="Password" placeholder="Password" required="">
		<ul class="tick w3layouts agileinfo">
			<li>
				<a href="#">Forgot Password?</a>
			</li>
		</ul>
		<div class="send-button wthree agileits">
			<input id="login" type="submit" value="Sign In">
			<div aria-live="assertive" aria-atomic="true" aria-relevant="text" class="mdl-snackbar mdl-js-snackbar">
				<div class="mdl-snackbar__text"></div>
				<button type="button" class="mdl-snackbar__action"></button>
			</div>
		</div>
	</div>
</body>
<!-- //Body -->
<script>
	$(document).ready(function () {
		$(document).keypress(function () {
			if (event.keyCode == 13) //回车键的键值为13
			{
				toLogin()
			}
		})
		$("#login").click(function () {
			toLogin()
		})

		function toLogin() {
			var Username = $('#Username').val()
			var Password = $('#Password').val()
			if (Username == "") {
				var notification = document.querySelector('.mdl-js-snackbar');
				notification.MaterialSnackbar.showSnackbar({
					message: "账号不能为空"
				})
			} else if (Password == "") {
				var notification = document.querySelector('.mdl-js-snackbar');
				notification.MaterialSnackbar.showSnackbar({
					message: "密码不能为空"
				})
			} else {
				$.ajax({
					type: "POST",
					url: "{:url('Index/logining')}",
					data: {
						"Username": Username,
						"Password": Password,
					},
					success: function (msg) {
						state = msg.substr(-1)
						if (state == 1) {
							location = "{:url('Index/index')}?book=1"
						} else {
							var notification = document.querySelector('.mdl-js-snackbar');
							notification.MaterialSnackbar.showSnackbar({
								message: "账号或密码错误"
							})
						}
					},
				})
			}
		}
	})
</script>


</html>